Belgelerim/ceng_491/implementation/doxygen/TraffEdu_Developers_Manual_Reference_ToSource/TrueColorToolBar.cpp

Go to the documentation of this file.
00001 // TrueColorToolBar.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "TrueColorToolBar.h"
00006 
00007 #ifdef _DEBUG
00008 #define new DEBUG_NEW
00009 #undef THIS_FILE
00010 static char THIS_FILE[] = __FILE__;
00011 #endif
00012 
00014 // CTrueColorToolBar
00015 
00016 CTrueColorToolBar::CTrueColorToolBar()
00017 {
00018 }
00019 
00020 CTrueColorToolBar::~CTrueColorToolBar()
00021 {
00022 }
00023 
00024 
00025 BEGIN_MESSAGE_MAP(CTrueColorToolBar, CToolBar)
00026         //{{AFX_MSG_MAP(CTrueColorToolBar)
00027                 // NOTE - the ClassWizard will add and remove mapping macros here.
00028         //}}AFX_MSG_MAP
00029 END_MESSAGE_MAP()
00030 
00032 // CTrueColorToolBar message handlers
00033 BOOL CTrueColorToolBar::LoadTrueColorToolBar(int nBtnWidth,
00034                                                                                          UINT uToolBar,
00035                                                                                          UINT uToolBarHot,
00036                                                                                          UINT uToolBarDisabled)
00037 {
00038         if (!SetTrueColorToolBar(TB_SETIMAGELIST, uToolBar, nBtnWidth))
00039                 return FALSE;
00040         
00041         if (!SetTrueColorToolBar(TB_SETHOTIMAGELIST, uToolBarHot, nBtnWidth))
00042                 return FALSE;
00043 
00044         if (uToolBarDisabled) {
00045         if (!SetTrueColorToolBar(TB_SETDISABLEDIMAGELIST, uToolBarDisabled, nBtnWidth))
00046                 return FALSE;
00047         }
00048 
00049         return TRUE;
00050 }
00051 
00052 
00053 BOOL CTrueColorToolBar::SetTrueColorToolBar(UINT uToolBarType,
00054                                                                         UINT uToolBar,
00055                                                                                     int nBtnWidth)
00056 {
00057         CImageList      cImageList;
00058         CBitmap         cBitmap;
00059         BITMAP          bmBitmap;
00060         CSize           cSize;
00061         int                     nNbBtn;
00062         
00063         if (!cBitmap.Attach(LoadImage(AfxGetInstanceHandle(),
00064                                                                   MAKEINTRESOURCE(uToolBar),
00065                                                                   IMAGE_BITMAP, 0, 0,
00066                                           LR_DEFAULTSIZE|LR_CREATEDIBSECTION)) ||
00067             !cBitmap.GetBitmap(&bmBitmap))
00068                 return FALSE;
00069 
00070         cSize  = CSize(bmBitmap.bmWidth, bmBitmap.bmHeight); 
00071         nNbBtn = cSize.cx/nBtnWidth;
00072         RGBTRIPLE* rgb          = (RGBTRIPLE*)(bmBitmap.bmBits);
00073         COLORREF   rgbMask      = RGB(rgb[0].rgbtRed,
00074                                       rgb[0].rgbtGreen,
00075                                                           rgb[0].rgbtBlue);
00076         
00077         if (!cImageList.Create(nBtnWidth, cSize.cy,
00078                                    ILC_COLOR24|ILC_MASK,
00079                                                    nNbBtn, 0))
00080                 return FALSE;
00081         
00082         if (cImageList.Add(&cBitmap, rgbMask) == -1)
00083                 return FALSE;
00084         SendMessage(uToolBarType, 0, (LPARAM)cImageList.m_hImageList);
00085         cImageList.Detach(); 
00086         cBitmap.Detach();
00087         
00088         return TRUE;
00089 }
00090 

Generated on Sun May 28 18:54:09 2006 for TraffEdu by  doxygen 1.4.6-NO